import {SHOW_ALERT,HIDE_ALERT} from './actionTypes'
const defaultValue ={
    // 文字信息
    alertMsg:'开心菜菜子',
    // alert类型  error错误 warning 警告 info一般 success成功
    alertType:'success',
    // alert 是否显示
    alertShow:false,
}
const reducer = (state=defaultValue,action)=>{
    const newState = JSON.parse(JSON.stringify(state))
    switch (action.type) {
        case SHOW_ALERT:
            newState.alertShow=true
            newState.alertMsg=action.value.msg
            newState.alertType=action.value.type
            break;
        case HIDE_ALERT:
             newState.alertShow=false
            // newState.alertMsg=action.value.msg
            // newState.alertType=action.value.type
        break;
        default:
            break;
    }
    return newState
}
export default reducer